
<h1>Product Categories List</h1>

<div id="admin_icon_edit">
<li><?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/images/icons/icon_add2.png'). ' Create Product Category', array('productCategories/create'));?></li>
</div>

<?php  $this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$dataProvider,
    'columns'=>array(
      array(
        'header'=>'No.',
        'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
      ),
      array(
      	'header'=>'Name',
      	'type' => 'raw',
      	'value'=>'($data->subProductCategoriesCount > 0) ? CHtml::link($data->name, Yii::app()->createUrl("productCategories/list", array("id"=>$data->id))) : $data->name'
      ),
      array(
      	'header'=>'Product',
      	'type' => 'raw',
      	'value'=>'($data->subProductCategoriesCount == 0) ? CHtml::link("See the products ($data->productsCount)", Yii::app()->createUrl("products/list", array("productCategoryId"=>$data->id))) : ""'
      ),      
      array(
        'header' => 'Display Order',
        'class'=>'CButtonColumn',
        'template'=>'{up} {down}',
        'buttons' => array(
          'up' => array
          (
            'label'=>'up image',
            'visible'=>'$data->display_order > 1',
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_up.png',
            'url'=>'Yii::app()->createUrl("productCategories/upDisplay", array("id"=>$data->id))',
          ),
          'down' => array
          (
            'label'=>'down image',
            'visible'=>'$data->display_order < $data->maxDisplayOrder',
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_down.png',
            'url'=>'Yii::app()->createUrl("productCategories/downDisplay", array("id"=>$data->id))',
          ),
        )
      ),
      array(
        'header'=>'Enable',
        'class'=>'CButtonColumn',
        'template'=>'{enable} {disable}',
        'buttons'=>array(
          'enable' => array(
            'imageUrl' => Yii::app()->request->baseUrl.'/images/icons/icon_enable.jpg',
            'visible'=>'$data->enable == true',
            'url'=>'Yii::app()->createUrl("productCategories/updateStatus", array("id"=>$data->id))',
            'click'=>'function(){if (confirm("Do you want to disable this data?")){return true; }else { return false;}}',
          ),
          'disable' => array(
            'imageUrl' => Yii::app()->request->baseUrl.'/images/icons/icon_disable.jpg',
            'visible'=>'$data->enable == false',
            'url'=>'Yii::app()->createUrl("productCategories/updateStatus", array("id"=>$data->id))',
            'click'=>'function(){if (confirm("Do you want to enable this data?")){return true; }else { return false;}}',
          )
        ),
      ),
      array(
        'header'=>'Edit',
        'class'=>'CButtonColumn',
        'template'=>'{update}',
        'buttons'=>array(
          'update' => array(
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_edit.jpg',
          )
        ),
      ),
      array(
        'header'=>'Delete',
        'class'=>'CButtonColumn',
        'template'=>'{delete}',
        'buttons'=>array(
          'delete' => array(
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_bin.jpg',
          )
        ),
      ),
    ),
  )); ?>
